Repository navigation
fix: read Lighter order and trade ids from the string fields (ORD-2039) - #616
Merged
Merged
Conversation
Contributor
|
📦 Preview published under the Install the exact version(s) — npm i @lifi/perps-sdk-provider-hyperliquid@0.0.0-preview-f336ff4
npm i @lifi/perps-sdk-provider-lighter@0.0.0-preview-f336ff4
npm i @lifi/perps-sdk@0.0.0-preview-f336ff4 |
QA Review — #616 (ORD-2039)Verdict: ✅ Approve · Critical 0 · High 0 · Medium 0 · Low 0 · Awaiting response 0 · Review type: 🆕 First review (focused direct pass, head SummaryReads Lighter order, client order and trade ids from the exact string fields ( FindingsNone. Verified against the clone at head
🔵 Notes (not findings)
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes
Linear: ORD-2039
Intent
Lighter order indexes are above 2^53 on every market with a market id of 31 or more.
JSON.parserounds these numbers. For example,9570149379440277becomes9570149379440276. The SDK read the numeric fields, soOrder.orderId,Order.clientOrderId,Fill.idandFill.orderIdwere wrong, andgetOrderdid not find the order. This PR reads the exact string fields that Lighter sends.What changed
types/fill.ts:LtTradedeclarestrade_id_str,ask_id_str,bid_id_str,ask_client_id_strandbid_client_id_strasstring.utils/mapFill.ts:Fill.idcomes fromtrade_id_str.Fill.orderIdcomes frombid_id_strorask_id_str.utils/mapOrder.ts:orderIdcomes fromorder_id.clientOrderIdcomes fromclient_order_id, and the mapper omits it when the value is"0".mapOrderUpdatesusesorder_idin the terminated list and in the dropped-row text.LighterProvider.ts: thegetOrderlookup comparesorder_id. The client order lookup comparesclient_order_id..changeset/ord-2039.md: patch for@lifi/perps-sdk-provider-lighter.Assumptions
"0". The mainnetrecentTradesresponse sendsask_client_id: 0withask_client_id_str: "0", and the OpenAPI spec declares these fields as required strings. A live authenticated order read was not done; a human run can verify it.ask_client_id_strandbid_client_id_strare declared because the API sends them. No code reads them at this time.wasm/, the numericorder_indexinsrc/types/action.tsandLtOrderBookOrderdo not change.Tests
mapFill.unit.spec.ts,mapOrder.unit.spec.tsandLighterProvider.unit.spec.tsuse the fixture id9570149379440277and assert the exact string in the output. The newLighterProviderlookup tests fail on the old code.LighterWsProvider.unit.spec.tssends the literal unsafe number on the wire, soJSON.parserounds it. The test asserts that the WebSocket output is equal to themapFillandmapOrderoutput.pnpm test:unitpasses in all packages (lighter 1243).pnpm check,check:types,check:types:specandbuildpass.Follow-ups
web-wasm, which takes the order index as a string. That issue exists already.Dependencies
None.